<?php
class AppContext {
	
	private static $instance = null;
	
	private $config;
	
	/**
	 * @var Zend_Controller_Request_Http
	 */
	private $request;
	
	public static function setup($config) {
		self::instance()->config = $config;
	}
	
	public static function setRequest(Zend_Controller_Request_Http $req) {
		self::instance()->request = $req;
	}
	
	public static function getBasePath() {
		return BASE_PATH;
	}
	
	public static function getApplicationPath() {
		return APP_PATH;
	}
	
	public static function getBaseURL() {
		return self::getConfiguration('url');
	}
	
	public static function getControllerName() {
		return self::instance()->request->getControllerName();
	}
	
	public static function getActionName() {
		return self::instance()->request->getActionName();
	}
	
	public static function getConfiguration($key) {
		return self::instance()->config[$key];
	}
	
	private static function instance() {
		if (self::$instance == null) {
			self::$instance = new AppContext();
		}
		
		return self::$instance;
	}
}